﻿using Firestarter.DB.Schema.BO;
using Firestarter.DM_DB.Logic;
using FireStarterModeller.BO;
using FireStarterModeller.Test;
using NUnit.Framework;

namespace Firestarter.DB_DM.Logic.Test
{
    [TestFixture]
    public class TestDBFactory_CreateDBPrimaryKey : TestBase
    {
        [Test]
        public void Test_CreateDBPrimaryKey_PrimaryKey()
        {
            //---------------Set up test pack-------------------
            DMClass @class = TestUtilsDMClass.CreateUnsavedValidDMClass();
            DMProperty dmProperty = TestUtilsShared.CreateUnsavedValidDMProperty(@class);
            @class.CreateObjectIdentity(dmProperty);
            DBFactory factory = TestDBFactory.CreateDBFactory();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            DBPrimaryKey dbPrimaryKey = factory.CreateDBPrimaryKey(@class,factory.CreateDBTable(@class));
            ////---------------Test Result -----------------------
            Assert.AreEqual(1, dbPrimaryKey.Columns.Count);
            Assert.AreSame(dmProperty.MappedDBColumnName, dbPrimaryKey.Columns[0].ColumnName);
        }
    }
}
